package com.ihr360.authority.sharing.model.dto;

import com.ihr360.commons.entityhandler.DateHandler;
import com.ihr360.commons.entityhandler.Ihr360ContextHandler;
import com.ihr360.commons.model.entity.NumberIdWithTimeAndCompanyId;
import com.ihr360.commons.model.type.ResourcePublicity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "auth_user_resource", uniqueConstraints = @UniqueConstraint(columnNames = {"companyId", "bizModel", "userId", "resourceId","publicity"}))
@EntityListeners(value = {Ihr360ContextHandler.class, DateHandler.class})
public class AuthUserResource extends NumberIdWithTimeAndCompanyId<Long> {


    /**
     * 功能模块
     */
    @Column(nullable = false, columnDefinition = "varchar(30)")
    private String bizModel;

    /**
     * 用户id
     */
    @Column(nullable = false, columnDefinition = "varchar(36)")
    private String userId;

    /**
     * 对应资源Id
     */
    @Column(nullable = false, columnDefinition = "varchar(36)")
    private String resourceId;

    /**
     * 冗余信息
     */
    @Column(nullable = false, columnDefinition = "varchar(36)")
    private String userAccount;

    /**
     * @see com.ihr360.commons.model.type.AccessPrivilege.Privilege
     */
    @Column(nullable = false, columnDefinition = "tinyint(8)")
    private int privilege;

    /**
     * @see ResourcePublicity.Publicity
     */
    @Column(nullable = false, columnDefinition = "tinyint(4) default 0")
    private int publicity;

    public String getBizModel() {
        return bizModel;
    }

    public void setBizModel(String bizModel) {
        this.bizModel = bizModel;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(String userAccount) {
        this.userAccount = userAccount;
    }

    public int getPrivilege() {
        return privilege;
    }

    public void setPrivilege(int privilege) {
        this.privilege = privilege;
    }

    public int getPublicity() {
        return publicity;
    }

    public void setPublicity(int publicity) {
        this.publicity = publicity;
    }

}